
package com.wwy.monitor.model.enumeration;

/**
 * @author tianquan.ld
 * @version V1.0
 * <p>Description: 监控类型枚举 </p>
 * @date 2019-10-29 16:49
 */
public enum MonitorTypeEnum {

    SERVICE_AVAILABLE(1, "服务探活"),
    DISK_FILE(2, "硬盘文件监控"),
    RAM_FILE(3, "内存文件监控"),
    DATABASE(4, "数据库监控");

    /**
     * 状态码
     */
    private int value;
    /**
     * 状态描述
     */
    private String desc;

    MonitorTypeEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static String parseDesc(int status) {
        String desc = parse(status);
        if (desc == null) {
            desc = SERVICE_AVAILABLE.getDesc();
        }
        return desc;
    }

    private static String parse(int status) {
        MonitorTypeEnum[] values = values();
        for (MonitorTypeEnum v : values) {
            if (v.getValue() == status) {
                return v.getDesc();
            }
        }
        return null;
    }

}